<?php

use Illuminate\Http\Request;

Route::namespace('Api')->middleware(['force-json'])->group(function (){

	Route::prefix('home')->group(function (){
		//首页信息
		Route::get('index','HomeController@index');

		//首页信息
		Route::get('goods','HomeController@goods');
	});

	//产品搜索
	Route::prefix('search')->group(function (){
	    Route::get('searchGoods','SearchController@searchGoods');
	    //分类产品搜索
	    Route::get('search','SearchController@Search');
	    //根据关键词搜索商品
	    Route::get('keyWordSearch','SearchController@keyWordSearch');
	    //过滤商品
	    Route::get('filterGoods','SearchController@filterGoods');
    });

	Route::prefix('category')->group(function(){
		//分类首页
		Route::get('categorys','CategoryController@categorys');
		//分类下的子分类
		Route::get('getChildCategory','CategoryController@getChildCategory');
		//分类商品 带分页
		Route::get('goods','CategoryController@goods');
	});

	//用户
	Route::prefix('user')->middleware(['jwt-check'])->group(function (){
	    //个人中心首页
	    Route::get('index','UserController@index');
		//用户信息
		Route::get('user_info','UserController@user_info');
		//更新用户信息
		Route::post('update','UserController@update');
		//用户评论
		Route::get('comments','UserController@commets');
		//更换头像
		Route::post('uploadThumb','UserController@uploadThumb');
		//发送短信验证码
		Route::post('sendMsg','UserController@sendMsg');
		//检查验证码
		Route::post('checkCode','UserController@checkCode');
		Route::post('changePswd','UserController@changePswd');

		//添加用户地址
		Route::post('userAddressAdd','UserController@userAddressAdd');
		//用户地址列表
		Route::get('userAddrList','UserController@userAddrList');
		//用户地址修改
		Route::get('userAddressEdit','UserController@userAddressEdit');
		//用户地址更新操作
		Route::post('userAddressUpdate','UserController@userAddressUpdate');
		//删除用户地址
		Route::get('delAddress','UserController@delAddress');
	});

	Route::prefix('coupons')->middleware(['jwt-check'])->group(function (){
        //我的优惠券列表
	    Route::get('index','CouponsController@index');
    });

	//支付宝支付
	Route::prefix('alipay')->group(function (){

		Route::get('order_pay','AlipayController@orderPay');

		//订单前端的回调地址
		Route::post('order_pay_return','AlipayController@orderPayReturn');
	});

	//支付宝订单异步通知
	Route::post('alipay/order_pay_notify','AlipayController@orderPayNotify');

	//余额支付
	Route::prefix('balance')->middleware(['jwt-check'])->group(function (){
	    //余额支付操作
	    Route::post('balancePay','BalancePayController@balancePay');
	    //检查支付密码
	    Route::post('checkPayPswd','BalancePayController@checkPayPswd');
    });

	//微信支付
	Route::prefix('wxpay')->group(function (){
		//预下单
		Route::get('orderPay','WeiXinPayController@orderPay');
	});

	//评论
	Route::prefix('comment')->middleware(['jwt-check'])->group(function(){
		//评论文章
		Route::post('store/{id}','CommentController@store');
		//删除留言
		Route::get('destroy/{id}','CommentController@destroy');
	});

	//图片上传 必须登录用户才能上传
	Route::post('uploadImg','BaseController@uploadImg')->middleware(['jwt-check']);

	//登录注册
	Route::prefix('login')->group(function (){
		//登录
		Route::post('login','LoginController@login');
		//发送注册邮箱验证码
		Route::post('sendRegEmailVerifyCode','LoginController@sendRegEmailVerifyCode');
		//微信登录
		Route::get('wxLogin','LoginController@wxLogin');
		//注册
		Route::post('register','LoginController@register');
		//邀请注册
		Route::post('inviteRegister','LoginController@inviteRegister');
		//退出
		Route::get('logout','LoginController@logout')->middleware(['jwt-check']);

	});

	//文章
	Route::prefix('article')->group(function(){
		//文章列表
		Route::get('index','ArticleController@index');

		//文章详情
		Route::get('show/{id}','ArticleController@show');
	});

	//商品
	Route::prefix('goods')->group(function (){
		//展示商品信息
		Route::get('show/{id}','GoodsController@show');

	});

	//购物车
	Route::prefix('cart')->middleware(['jwt-check'])->group(function (){
		//加入购物车
		Route::post('store','CartController@store');
		//更改购物车数量
		Route::post('changeCartNumber','CartController@changeCartNumber');
		//删除购物车
		Route::get('destroy','CartController@destroy');
		//显示购物车列表
		Route::get('index','CartController@index');
		//订单结算页
		Route::post('settlement','CartController@settlement');
		//订单确认下单
		Route::post('confirmOrder','CartController@confirmOrder');
		//检查收货地址是否设置
		Route::get('checkAddrCount','CartController@checkAddrCount');
	});

    /**
     * 订单类
     */
	Route::prefix('order')->middleware(['jwt-check'])->group(function (){
	    //订单支付页面展示
        Route::get('order_pay_page','OrderController@order_pay_page');
        //订单删除
        Route::get('destroy','OrderController@destroy');
        //订单详情
        Route::get('show','OrderController@show');
        //订单列表首页
        Route::get('index','OrderController@index');

        //商品详情页面订单立即下单
        Route::post('buy_goods','OrderController@buyGoods');
        //商品详情页面->订单确认下单
        Route::post('createOrder','OrderController@createOrder');
    });

	//秒杀商品展示类
    Route::prefix('sec_kill')->group(function (){
        //秒杀商品列表
        Route::get('index','SecKillController@index');
        //获得秒杀商品规格库存
        Route::get('getInventory','SecKillController@getInventory');
        //展示秒杀商品
        Route::get('goods/{id}','SecKillController@goods');
    });

    //秒杀商品动作
    Route::prefix('kill_goods')->middleware(['jwt-check'])->group(function (){
        //获得秒杀商品规格库存
        Route::post('killGoodsToConfirm','SecKillController@killGoodsToConfirm');
        //秒杀订单确认
        Route::post('getConfirmInfo','SecKillController@getConfirmInfo');
        //创建秒杀订单
        Route::post('createOrder','SecKillController@createOrder');
    });

    //微信
	Route::prefix('wechat')->group(function (){
		//服务验证
		Route::any('server','WechatController@server');
		//获得jssdk验证参数
		Route::get('getJsSdkParams','WechatController@getJsSdkParams');
	});
});
